<style scoped>

.extendGroup {
  float: right;
  margin-right: 20px;
  opacity: 0;
}

.el-tree-node__content:hover .extendGroup {
  opacity: 1;
}
.list_title{padding-bottom: 30px;}
</style>

<template>
  <div>

      <template v-if="routerPath=='currwithverify'" >
        <div v-loading="loading">
          <!--工具条-->
          <el-col :span="24" class="toolbar toolbar_header" style="padding-bottom: 0px;">
            <el-form :inline="true" :model="filters">
              <el-form-item label="状态:">
                <el-select v-model="filters.status" placeholder="请选择">
                  <el-option label="全部" value=""></el-option>
                  <el-option label="待审核" value="30"></el-option>
                  <el-option label="已转出" value="31"></el-option>
                  <el-option label="拒绝" value="32"></el-option>
                  <el-option label="撤销" value="33"></el-option>
                  <el-option label="打币中" value="34"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="币种:">
                <el-select v-model="filters.coinId" placeholder="请选择">
                  <el-option label="全部" value=""></el-option>
                  <el-option v-for="item in currList" :label="item.name" :value="item.coinId" :key="item.coinId"></el-option>
                </el-select>
              </el-form-item>
               <el-form-item label="开始时间">
                <el-date-picker type="date" placeholder="开始时间" v-model="filters.dateStart" style="width: 100%;"></el-date-picker>
              </el-form-item>
              <el-form-item label="结束时间">              
                <el-date-picker type="date" placeholder="结束时间" v-model="filters.dateEnd" style="width: 100%;"></el-date-picker>
              </el-form-item>
              <el-form-item label="用户名:">
                <el-input v-model="filters.name" placeholder="等值匹配"></el-input>
              </el-form-item>              
              <el-form-item>
                <el-button type="primary" v-on:click="fetchData">搜索</el-button>
              </el-form-item>
            </el-form>
          </el-col>        
        <!-- table start  -->
        <el-table :data="list" style="width: 100%" max-height="1000">
          <el-table-column width="37">
            <template scope="scope">
              <img src="../assets/img/sysFile.gif">
            </template>
          </el-table-column> 
          <el-table-column label="ID"     type="index"    width="60">
          </el-table-column>
          <el-table-column prop="userName" label="用户名" >
          </el-table-column>
          <!--     
          <el-table-column prop="currId" label="币种ID" width="25">
          </el-table-column> -->
          <el-table-column prop="coinTitle" label="币种名称" width="42">
          </el-table-column>
          <el-table-column prop="amount" label="提现金额" width="56" >
          </el-table-column>       
          <el-table-column prop="fee" label="手续费" width="70">
          </el-table-column>
          <el-table-column prop="coinWalletId" label="钱包标识" width="253">
          </el-table-column>
          <el-table-column prop="address" label="钱包地址" width="310">
          </el-table-column>
          <el-table-column prop="idNo" label="交易ID" width="140" >
          </el-table-column>
          <el-table-column prop="status" label="提现状态" :formatter="formatSex">
          </el-table-column>
          
          <el-table-column prop="createTime" label="申请时间" >
          </el-table-column>
          
          <el-table-column prop="realAmount" label="确认金额">
          </el-table-column>
          <el-table-column prop="remark" label="确认备注">
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">       
              <span class="span_btn" v-if="scope.row.status==30"  @click="toggleStatus(scope.$index, scope.row)" >审核</span>
             
            </template>
          </el-table-column>
        </el-table>
          <!--工具条-->
        <el-col :span="24" class="toolbar toolbar_footer">
          <el-pagination v-if="total" background layout="prev, pager, next,total,jumper" @current-change="handleCurrentChange" :page-size="showCount" :total="total" style="float:right;">
          </el-pagination>
        </el-col>
        <!-- table end  -->
         <!-- 提现审核 -->
        <el-dialog title="提现审核" top="0"  class="form_part sellorder" :visible.sync="withVerifyVisible"  :close-on-click-modal="false">
            <el-form :model="withVerify" class="" label-width="100px" :rules="withVerifyRules" ref="withVerify">
                                     
                <el-form-item label="状态" prop="status">
                  <el-select v-model="withVerify.status" placeholder="请选择状态">
                    <el-option label="完成" value="31" ></el-option>
                    <el-option label="审核拒绝" value="32" ></el-option>                    
                  </el-select>
                </el-form-item>    
                
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="withVerify.remark" placeholder="请输入备注说明" auto-complete="off"></el-input>
                </el-form-item>
                
                <el-form-item class="btn_add">
                   <el-button style="width:100%" type="primary"  @click.native="sureVerify('withVerify')" :loading="withVerifyLoading">确定</el-button>
                </el-form-item>
             
            </el-form>
            <!-- <div slot="footer" class="dialog-footer">
              <el-button style="width:100%" type="primary"  @click.native="addSubmit('addForm')" :loading="addLoading">添加</el-button>
             
            </div> -->
        </el-dialog>
      </div>
      </template>
       <template v-else>
        <router-view></router-view>
      </template>
  </div>

  
  
</template>

<script>
import * as cnyrecharge from '../api/cnyrecharge';
import * as currency from '../api/currency'

let myMixin = {
  data: function() {
    return { cnyrecharge }
  }
}

export default {
  mixins: [myMixin],
  data() {
    return {
      withVerifyVisible:false,
      withVerifyLoading:false,
      withVerify:{},
      withVerifyRules:{
        status:[
            { required: true, message: '请选择状态', trigger: 'change' }        
        ],
        remark:[
            { required: true, message: '请输入备注说明', trigger: 'blur' }
        
        ],

      },
      filters:{},
      isDel:true,
      isEdit:true,
      isReleRole:true,
      isReleGroup:true,
      total: 10,
      page: 1,
      showCount:10,
      routerPath:'',
      addLoading:false,//
      editLoading:false,//
      list: [],
      canReset: true,
      loading: false,
      groupId:'',//组id
      userId:'',//用户id
      verifyItem:'',//审核数据
      currList:[],
    }
  },
  methods: {
     toggleStatus:function(index,row){
      //状态操作--审核
      this.withVerifyVisible=true;
     // this.sureVerify(row);
     this.verifyItem=row;
     
    },
    sureVerify(){
      this.$refs.withVerify.validate((valid) => {
        if (valid) {
          let para={
            idNo:this.verifyItem.idNo,
            status:this.withVerify.status,
            remark:this.withVerify.remark,
          }
          console.log(para);
          // return;
          cnyrecharge.currWithVerify.r(para).then((res) => {
            console.log(res)

            if(res.data.retCode==1){
              this.$message("操作成功")
              this.fetchData(true);
              this.withVerifyVisible=false;

            }else{
              this.$message.error(res.data.retMsg);
            }
              this.loading = false;
            
          });
        }else{
          console.log('error submit!!');
          return false;

        }

      })

    },
     //状态转换

    formatSex: function (row, column) {
      return row.status == 30 ? '待审核' : row.status == 32 ? '拒绝' :row.status == 31 ? '完成' :row.status == 33 ? '用户撤销' :row.status == 34 ? '打币中' : '处理中';
    },
    handleCurrentChange(val) {
      this.page = val;
      // this.getcnyrecharge();
      this.fetchData();
    },

    fetchData(init) {
      this.loading = true;
    /*  if(!this.$_has([cnyrecharge.request])){
        this.$message("暂无权限");
        this.loading = false;

        return;
      }*/
      let para = {
          // groupId:this.groupId,
          showCount:this.showCount,
          currentPage:this.page,//当前查询页
          userName:this.filters.userName,
          coinId:this.filters.coinId,
          dateStart:this.filters.dateStart,
          dateEnd:this.filters.dateEnd,
          status:this.filters.status,

        };
      console.log(para)
      cnyrecharge.currWithList.r(para).then((res) => {
        console.log(res)
        if(res.data.retCode==1){
          console.log("123");          
          this.total=parseInt(res.data.data.totalRow);
        
          this.list = res.data.data.list;
        }else{
          this.$message.error(res.data.retMsg);
        }   
      

        this.loading = false;
      });
    },
    fetchDataCurr() {
      //获取币种列表
 
     let para = {
          showCount:this.showCount,
          currentPage:this.page,//当前查询页
          // name:this.filters.name
        };

      currency.request.r(para).then((res) => {
        console.log(res);
        if(res.data.retCode==1){
          this.currList=res.data.data.list
        }else{
          this.$message.error(res.data.retMsg)
        }
    
      });
    },
    requestNotAllowed: function(){
      cnyrecharge.notAllowed.r();
    }
  },
 /* watch: {
          // 如果路由有变化，会再次执行该方法
          "$route": function(){
            this.routerPath=this.$route.path.split("/").pop();
            // this.groupId="";
            this.fetchData(true)

          }
  },*/
  created() {
   /* this.isReleRole=this.$_has([cnyrecharge.releRolesUser]);
    this.isReleGroup=this.$_has([cnyrecharge.releGroupUser]);
    this.isEdit=this.$_has([cnyrecharge.modify]);
    this.isDel=this.$_has([cnyrecharge.remove]);
    if(this.$route.query.groupId!=undefined&&this.$route.query.groupId!="undefined"&&this.$route.query.groupId!=""){
      this.groupId=this.$route.query.groupId;
    }*/

    
    /*console.log(this.$route.path.split("/").pop())*/
    this.routerPath=this.$route.path.split("/").pop();
    this.fetchData(true)
    this.fetchDataCurr();

  }
}
</script>